package com.pzh.guli.service.edu.controller.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pzh.guli.service.base.result.Result;
import com.pzh.guli.service.edu.pojo.Teacher;
import com.pzh.guli.service.edu.pojo.vo.TeacherVo;
import com.pzh.guli.service.edu.service.ITeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("api/edu/teacher")
public class ApiTeacherController {
    @Autowired
    private ITeacherService teacherService;
    @GetMapping("list/{page}/{limit}")
    public Result listPage(@PathVariable Long page, @PathVariable Long limit, TeacherVo teacherVo){
        Page<Teacher> pageParam=new Page(page,limit);
        IPage iPage = teacherService.selectPage(pageParam, teacherVo);
        List<Teacher> records=iPage.getRecords();
        long total = iPage.getTotal();
        return Result.ok().data("total",total).data("rows",records);
    }
    //前台热门老师
    @GetMapping("topTeacher")
    public Result getTopTeacher(){
       List<Teacher> teachers= teacherService.getTopTeacher();
       return Result.ok().data("items",teachers);
    }
}
